package com.zoshine.zzg.controller;

import com.github.pagehelper.PageInfo;
import com.zoshine.zzg.base.BaseResponse;
import com.zoshine.zzg.pojo.PrisonerInfo;
import com.zoshine.zzg.respons.AppResponse;
import com.zoshine.zzg.service.PrisonerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 犯人信息Controller
 * @author 田沛凌
 * @time 2017年7月6日 下午5:32:30
 */
@RestController
@RequestMapping(value = "/prisonerInfo", method = RequestMethod.POST)
public class PrisonerController {

	private PrisonerInfoService prisonerInfoService;

	@Autowired
	public void setPrisonerInfoService(PrisonerInfoService prisonerInfoService) {
		this.prisonerInfoService = prisonerInfoService;
	}

	/**
	 * 查询犯人信息集合(分页)
	 * @param prisonerInfo;
	 * @return listPrisonerInfo
	 */
	@RequestMapping("/pagePrisonerInfo")
	public BaseResponse pagePrisonerInfo(PrisonerInfo prisonerInfo){
		
		List<PrisonerInfo> listPrisonerInfo = prisonerInfoService.list(prisonerInfo);
		
		return new AppResponse(new PageInfo<>(listPrisonerInfo));
	}
	/**
	 * 查询犯人信息集合
	 * @param prisonerInfo;
	 * @return listPrisonerInfo
	 */
	@RequestMapping("/listPrisonerInfo")
	public BaseResponse listPrisonerInfo(PrisonerInfo prisonerInfo){

		List<PrisonerInfo> listPrisonerInfo = prisonerInfoService.list(prisonerInfo);

		return new AppResponse(listPrisonerInfo);
	}
	/**
	 * 获取单个犯人信息
	 * @param id (犯人信息ID)
	 */
	@RequestMapping("/getPrisonerInfo")
	public BaseResponse getPrisonerInfo(Long id){
	    PrisonerInfo prisonerInfo = prisonerInfoService.get(id);
	    return new AppResponse(prisonerInfo);
	}
	/**
	 * 删除单个犯人信息
	 * @param id (犯人信息ID)
	 */
	@RequestMapping("/delPrisonerInfo")
	public BaseResponse delPrisonerInfo(Long id){
	    //prisonerInfoService.del(id);
	    return  AppResponse.OK;
	}
	/**
	 * 新增犯人信息
	 * @param prisonerInfo;
	 */
	@RequestMapping("/addPrisonerInfo")
	public BaseResponse addPrisonerInfo(PrisonerInfo prisonerInfo){
	    prisonerInfoService.add(prisonerInfo);
	    return  AppResponse.OK;
	}
	/**
	 * 修改犯人信息
	 * @param prisonerInfo;
	 */
	@RequestMapping("/editPrisonerInfo")
	public BaseResponse editPrisonerInfo(PrisonerInfo prisonerInfo){
	    prisonerInfoService.edit(prisonerInfo);
	    return  AppResponse.OK;
	}

	/**
	 * 查询监区
	 * @return 监区集合
	 */
	@RequestMapping("listArea")
	public BaseResponse listArea(){
		List<PrisonerInfo> listPrisonerInfo=prisonerInfoService.listArea();
		return new AppResponse(listPrisonerInfo);
	}
	/**
	 * 查询分监区
	 * @return 分监区集合
	 */
	@RequestMapping("listSubArea")
	public BaseResponse listSubArea(){
		List<PrisonerInfo> listPrisonerInfo=prisonerInfoService.listSubArea();
		return new AppResponse(listPrisonerInfo);
	}
	/**
	 * 查询监室
	 * @return 监室集合
	 */
	@RequestMapping("listRoom")
	public BaseResponse listRoom(){
		List<PrisonerInfo> listPrisonerInfo=prisonerInfoService.listRoom();
		return new AppResponse(listPrisonerInfo);
	}
}
